package com.xiaofeng.pochi.controller;

import com.xiaofeng.pochi.common.Page;
import com.xiaofeng.pochi.common.Result;
import com.xiaofeng.pochi.pojo.ShopOrderComment;
import com.xiaofeng.pochi.pojo.dto.ShopOrderCommentDto;
import com.xiaofeng.pochi.pojo.vo.ShopOrderCommentVo;
import com.xiaofeng.pochi.service.ShopOrderCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA
 *
 * @Author: chc
 * @Date: 2022/09/23/23:26
 * @Description:
 */
@RestController
@RequestMapping("/orderComment")
public class ShopOrderCommentController {

    @Autowired
    private ShopOrderCommentService shopOrderCommentService;


    /**
     * 前台评价
     * @param list
     * @return
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    public Result<?> save(@RequestBody List<ShopOrderCommentDto> list) {
        shopOrderCommentService.save(list);
        return new Result<>("评价成功");
    }

    /**
     * 分页查询
     * @param page
     * @return
     */
    @RequestMapping(value = "/getByPage", method = RequestMethod.POST)
    public Result<Page<ShopOrderCommentVo>> getByPage(@RequestBody Page<ShopOrderCommentVo> page) {
        page = shopOrderCommentService.getByPage(page);
        return new Result<>(page);
    }
    
}
